class Solution
{
public:
    int countConsistentStrings(string allowed, vector<string> &words)
    {
        int allowFlag = 0;
        for (char c : allowed)
        {
            allowFlag |= 1 << (c - 'a');
        }
        int consistentCount = 0;
        for (auto &word : words)
        {
            bool allow = true;
            for (char c : word)
            {
                if (!(allowFlag & (1 << (c - 'a'))))
                {
                    allow = false;
                    break;
                }
            }
            if (allow)
            {
                ++consistentCount;
            }
        }
        return consistentCount;
    }
};